import './App.css';
import {BrowserRouter, Routes, Route, unstable_HistoryRouter as HistoryRouter  } from "react-router-dom"
import {history} from "@/utils/history"
import Login from "@/pages/Login"
import Layout from "@/pages/Layout"
import {AuthComponent} from "@/components/AuthComponent"
import Publish from "@/pages/Publish"
import Home from "@/pages/Home"
import Article from "@/pages/Article"

function App() {
  return ( 
    <HistoryRouter history={history}>
      <Routes>
        {/* 创建路由对应关系 */}
        {/* Layout需要做鉴权处理 */}
        <Route path="/" element={
          <AuthComponent  >
            <Layout />
          </AuthComponent>
        }>
          <Route index element={<Home />}></Route>
          <Route path="publish" element={<Publish />}></Route>
          <Route path="article" element={<Article />}></Route>
        </Route>
        {/* 登录不需要鉴权 */}
        <Route path="/login" element={<Login />}></Route>
      </Routes>
    </HistoryRouter>
  );
}

export default App;
